﻿using System.Collections.Generic;

namespace PT.NoteDetection.Util {
    public abstract class WindowFunction<T> : IEnumerable<T> {
        protected readonly CircularArrayQueue<T> data;

        public int Width { get { return data.Capacity; } }
        public int Count { get { return data.Count; } }

        protected WindowFunction(int width) {
            data = new CircularArrayQueue<T>(width);
        }

        public void Advance(T newData) {
            data.Add(newData);
        }

        public abstract T Value(int index);

        public T this[int index] {
            get { return data[index]; }
        }

        public IEnumerator<T> GetEnumerator() {
            return data.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
            return data.GetEnumerator();
        }
    }
}
